/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao.ibatis;

import com.ibatis.sqlmap.client.SqlMapClient;
import model.dao.ActaElectoralDao;
import model.bean.ActaElectoral;
import java.util.List;
import java.util.Map;
import model.common.ibatis.IbatisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

/**
 * @Archivo ActaElectoralDaoIbatis.java
 * @Fecha                @Autor   @Cambios
 * 21/01/2011 04:06:26 PM       moshiro
 */
@Repository
public class ActaElectoralDaoIbatis extends SqlMapClientDaoSupport implements ActaElectoralDao {

    @Autowired
    public ActaElectoralDaoIbatis(SqlMapClient arg) {
        setSqlMapClient(arg);
    }

    @Override
    public Long agregarActaElectoral(ActaElectoral actaElectoral) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(actaElectoral);
        return ((Long) getSqlMapClientTemplate().queryForObject("agregarActaElectoral", parameterMap)).longValue();
    }

    @Override
    public Integer modificarActaElectoral(ActaElectoral actaElectoral) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(actaElectoral);
        return ((Integer) getSqlMapClientTemplate().update("modificarActaElectoral", parameterMap));
    }

    @Override
    public Integer eliminarActaElectoral(Long codigo) throws DataAccessException {
        ActaElectoral actaElectoral = new ActaElectoral();
        actaElectoral.setCodigo(codigo);
        return ((Integer) getSqlMapClientTemplate().delete("eliminarActaElectoral", actaElectoral));
    }

    @Override
    public List<ActaElectoral> listarActaElectoral(ActaElectoral actaElectoral) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(actaElectoral);
        return getSqlMapClientTemplate().queryForList("listarActaElectoral", parameterMap);
    }
}
